Expand description
A library for accessing GPIO lines on Linux platforms using the GPIO character device.
Lines are requested and manipulated using the request
module.
The lines available on specific chips can be discovered using the chip
module.
The lines available on the system can be discovered by name using the find_named_line
and find_named_lines
functions, or using the iterator returned by lines
.
§Example Usage
Request an input line and output line, and read from the input and change the output to that value:
use gpiocdev::line::{Bias, Value};
let req = gpiocdev::Request::builder()
.on_chip("/dev/gpiochip0")
.with_line(3)
.as_input()
.with_bias(Bias::PullUp)
.with_line(4)
.as_output(Value::Inactive)
.request()?;
let value = req.value(3)?;
req.set_value(4, value)?;
Monitor a line for debounced edges:
let req = gpiocdev::Request::builder()
.on_chip("/dev/gpiochip0")
.with_line(5)
.with_edge_detection(gpiocdev::line::EdgeDetection::BothEdges)
.with_debounce_period(std::time::Duration::from_millis(5))
.request()?;
for edge in req.edge_events() {
println!("{edge:?}");
}
Re-exports§
Modules§
- Asynchronous wrappers for the async-io reactor.
- Types and functions specific to chips.
- Types specific to lines.
- Types and functions related to requesting lines.
- Asynchronous wrappers for the Tokio reactor.
Structs§
- The info for a line discovered in the system.
- An iterator for all lines in the system available to the caller.
Enums§
- The uAPI ABI versions available to interact with the kernel.
- Errors returned by
gpiocdev
functions.
Functions§
- Detect the most recent uAPI ABI supported by the platform.
- Find the chip hosting a named line, and the line offset on that chip.
- Find a collection of named lines.
- An iterator over all the GPIO lines visible to the caller.
- Check if the platform and library support a specific ABI version.
Type Aliases§
- The result for
gpiocdev
functions.